//
//  ZYMainController.m
//  VeiBo
//
//  Created by apple on 16/12/2.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "ZYMainController.h"
#import "ZYTabBar.h"
#import "ZYNavigationController.h"

@interface ZYMainController ()
// <ZYTabBarDelegate>

@end

@implementation ZYMainController

- (void)viewDidLoad {
    [super viewDidLoad];
    [[UITabBar appearance] setBarTintColor:[UIColor yellowColor]];
    ZYTabBar *tabbar = [[ZYTabBar alloc] init];
    [self setValue:tabbar forKey:@"tabBar"];
    [self setupUI];
//    tabbar.delegateNew = self;
    tabbar.buttonBlock = ^{
        NSLog(@"按钮点击弹出控制器");
    };
    
}
- (void)setupUI{

    [self addChildViewController:@"ZYHomeController" title:@"首页" imageName:@"tabbar_home"];
    [self addChildViewController:@"ZYMessageController" title:@"消息" imageName:@"tabbar_message_center"];
    [self addChildViewController:@"ZYDiscoverController" title:@"发现" imageName:@"tabbar_discover"];
    [self addChildViewController:@"ZYProfileController" title:@"我" imageName:@"tabbar_profile"];

}

- (void)addChildViewController:(NSString *)className title:(NSString*)title imageName:(NSString *)imageName{
    Class class = NSClassFromString(className);
    UIViewController* Vc = [[class alloc] init];
    Vc.title = title;
    [Vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor orangeColor]} forState:(UIControlStateSelected)];
    Vc.tabBarItem.image = [UIImage imageNamed:imageName];
    Vc.tabBarItem.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",imageName]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    ZYNavigationController* nav = [[ZYNavigationController alloc] initWithRootViewController:Vc];
    [self addChildViewController:nav];
}

//- (void)composeButtonClickOfTabBar{
//    
//    NSLog(@"按钮点击弹出控制器");
//}
@end
